package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbDdos;
import com.ruoyi.system.service.ITbDdosService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * DDOS攻击表Controller
 * 
 * @author ruoyi
 * @date 2025-02-20
 */
@RestController
@RequestMapping("/system/ddos")
public class TbDdosController extends BaseController
{
    @Autowired
    private ITbDdosService tbDdosService;

    /**
     * 查询DDOS攻击表列表
     */
    @PreAuthorize("@ss.hasPermi('system:ddos:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbDdos tbDdos)
    {
        startPage();
        List<TbDdos> list = tbDdosService.selectTbDdosList(tbDdos);
        return getDataTable(list);
    }

    /**
     * 导出DDOS攻击表列表
     */
    @PreAuthorize("@ss.hasPermi('system:ddos:export')")
    @Log(title = "DDOS攻击表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbDdos tbDdos)
    {
        List<TbDdos> list = tbDdosService.selectTbDdosList(tbDdos);
        ExcelUtil<TbDdos> util = new ExcelUtil<TbDdos>(TbDdos.class);
        util.exportExcel(response, list, "DDOS攻击表数据");
    }

    /**
     * 获取DDOS攻击表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ddos:query')")
    @GetMapping(value = "/{ddosId}")
    public AjaxResult getInfo(@PathVariable("ddosId") Integer ddosId)
    {
        return success(tbDdosService.selectTbDdosByDdosId(ddosId));
    }

    /**
     * 新增DDOS攻击表
     */
    @PreAuthorize("@ss.hasPermi('system:ddos:add')")
    @Log(title = "DDOS攻击表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbDdos tbDdos)
    {
        return toAjax(tbDdosService.insertTbDdos(tbDdos));
    }

    /**
     * 修改DDOS攻击表
     */
    @PreAuthorize("@ss.hasPermi('system:ddos:edit')")
    @Log(title = "DDOS攻击表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbDdos tbDdos)
    {
        return toAjax(tbDdosService.updateTbDdos(tbDdos));
    }

    /**
     * 删除DDOS攻击表
     */
    @PreAuthorize("@ss.hasPermi('system:ddos:remove')")
    @Log(title = "DDOS攻击表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ddosIds}")
    public AjaxResult remove(@PathVariable Integer[] ddosIds)
    {
        return toAjax(tbDdosService.deleteTbDdosByDdosIds(ddosIds));
    }
}
